package IO;

import IO.ImageManager;

import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws IOException {
        System.out.println("=== 图片下载系统 ===");
        System.out.println("1. 下载图片");
        System.out.println("2. 查看所有图片");
        System.out.println("3. 搜索图片");
        System.out.println("4. 退出\n");

        int key=0;
        ImageManager imagemanager=new ImageManager();
        while (key !=4) {
            // 创建 Scanner 对象，用于读取用户输入
            Scanner scanner = new Scanner(System.in);
            System.out.print("请输入你选择使用的功能：");
            key= scanner.nextInt(); // 读取一行字符串
            switch (key) {
                case 1:
                    Scanner scanner1 = new Scanner(System.in);
                    System.out.print("请输入你要下载的图片的地址：");
                    String URL = scanner1.nextLine(); // 读取一行字符串
                    imagemanager.downloadImage(URL);
                    break;
                case 2:
                    imagemanager.listImages();
                    break;
                case 3:
                    Scanner scanner2 = new Scanner(System.in);
                    System.out.print("请输入你要查找的图片的名字：");
                    String name = scanner2.nextLine(); // 读取一行字符串
                    imagemanager.searchImage(name);
                    break;
                default:
                    break;
            }
        }
    }
}